package com.czh.listeners;

import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author chenzhihua
 * @Date 2024/4/30
 */
@Component
public class MqListener {

    /**
     * 监听消息并处理消息(快速入门)
     *
     * @param msg 类型和发送者那边的数据结构一致
     */
    @RabbitListener(queues = "simple.queue")
    public void listenSimpleQueue(String msg) {
        System.out.println("消费者收到了消息: " + msg);
    }

    /**
     * 监听消息并处理消息（WordQueue）
     *
     * @param msg 类型和发送者那边的数据结构一致
     */
    @RabbitListener(queues = "work.queue")
    public void listenWordQueue1(String msg) {
        System.out.println("消费者收到了消息: " + msg);
    }

    @RabbitListener(queues = "work.queue")
    public void listenWordQueue2(String msg) {
        System.out.println("消费者收到了消息: " + msg);
    }
}
